import request from "@/utils/request.js";

export default {
    templateQuery: (params) => request.post("/sqlTemplate/searchByPage", params),
    getTreeByCode: (params) => request.post("/common/getTreeByCode", params),
    getOptions: (params) => request.post("/common/getOptions", params),
    getPageConditions: (params) => request.post("/sqlTemplate/getPageConditions", params),
    save: (model, table, params) => {
        return request.post(`/curd/save/${model}/${table}`, params)
    },
    getById: (model, table, params) => {
        return request.post(`/curd/getById/${model}/${table}`, params)
    },
    del: (model, table, params) => {
        return request.post(`/curd/del/${model}/${table}`, params)
    },
    delbatch: (model, table, params) => {
        return request.post(`/curd/delbatch/${model}/${table}`, params)
    },
    logicDel: (model, table, params) => {
        return request.post(`/curd/logicDel/${model}/${table}`, params)
    },
    getCheckRules: (model, table, params) => {
        return request.post(`/curd/getCheckRules/${model}/${table}`, params)
    },

    uploadImg(file, params) {
        let form = new FormData();
        form.add("file", file);
        if (params) {
            for (let key in params) {
                form.add(key, params[key]);
            }
        }
        return request.upload("/file/imgUpload", form);
    }
}